<?php

Yii::import('application.modules.news.models.News');
Yii::import('application.modules.news.models.NewsCategories');

class DefaultController extends Controller {

    /**
     * Lists all models.
     */
    public $layout = '//layouts/column1';

    public function init() {
        Yii::app()->theme = 'home';
    }

    public function findNews($id) {
        $criteria = new CDbCriteria(array(
            'order' => 'create_time DESC',
        ));
        $criteria->limit = 5;
        $criteria->condition = 'status = 1 and category_id =' . $id;
        $model = News::model()->findAll($criteria);
        return $model;
    }

    public function actionIndex() {
        $criteria = new CDbCriteria;
        $criteria->addSearchCondition('rank', NewsCategories::CENTER);
        $model = NewsCategories::model()->findAll($criteria);
        $this->render('index', array('model' => $model));
    }

}